import React from 'react'

import { add, subtract, getQuery } from '../index'

// More on default export: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
export default {
  title: 'Example/utils'
}

// More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args
const Template = (args) => (
  <div>
    <button onClick={() => alert(`结果为 ${add(args.a, args.b)}`)}>点击获取 add 结果</button>
    <br />
    <br />
    <button onClick={() => alert(`结果为 ${subtract(args.a, args.b)}`)}>
      点击 subtract 获取结果
    </button>
    <br />
    <br />
    <button onClick={() => alert(`结果为 ${getQuery(args.key)}`)}>点击 getQuery 获取结果</button>
  </div>
)

export const Simple = Template.bind({})
Simple.argTypes = {
  a: {
    control: { type: 'number' }
  },
  b: {
    control: { type: 'number' }
  },
  key: {
    control: { type: 'text' }
  }
}
Simple.args = {
  a: null,
  b: null,
  key: ''
}
